import {
  getLevelFirstJson,
  getLevelZeroJson,
  getSelectDataMapList,
  getTenantID,
} from '@/utils';
import { VersionManageAPI } from '../common/type';

/** 定义版本搜索字段信息 */
const getVersionManageSearchColumns = (
  loadMdicMap: Record<string, any>,
  /** 根据头部key参数 展示不用的搜索框 */
  switchObj: Record<string, any>,
): VersionManageAPI.IHeaderSearchType => {
  /** 版本类型 */
  let typeSelect = getSelectDataMapList(
    loadMdicMap?.data?.obj?.[`${getTenantID()}1201`],
    'name',
    'id',
  );

  /** 审核状态 */
  let stateSelect = getSelectDataMapList(
    loadMdicMap?.data?.obj?.[`${getTenantID()}1202`],
    'name',
    'id',
  );

  /** 升级内容 */
  let cancelSelect = getSelectDataMapList(
    loadMdicMap?.data?.obj?.[`${getTenantID()}1203`],
    'name',
    'id',
  );

  let orgDeptList: any[] = getLevelZeroJson();

  let switchSearch: VersionManageAPI.ISearchList = [];
  if (switchObj?.key == 'MyVersionManageTab') {
    switchSearch.push(
      {
        name: 'versionType',
        label: '版本类型',
        placeholder: '版本类型',
        componentType: 'Select',
        allowClear: true,
        dataSource: [
          {
            name: '安卓端',
            value: '0',
          },
          {
            name: '苹果端',
            value: '1',
          },
          {
            name: '电脑端',
            value: '2',
          },
        ],
        md: 6,
        sm: 24,
        whetherSenior: false,
      },
      // {
      //   name: 'publicNum',
      //   label: '版本号',
      //   placeholder: '版本号',
      //   componentType: 'Input',
      //   allowClear: true,
      //   md: 4,
      //   sm: 24,
      //   whetherSenior: false,
      // },
      {
        name: 'upgradeNote',
        placeholder: '升级内容',
        label: '升级内容',
        componentType: 'Input',
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: false,
      },
      {
        name: 'isPublic',
        placeholder: '版本状态',
        label: '版本状态',
        componentType: 'Select',
        dataSource: [
          {
            name: '未发布',
            value: '0',
          },
          {
            name: '发布上线',
            value: '1',
          },
          {
            name: '历史版本',
            value: '2',
          },
        ],
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: false,
      },
      {
        name: 'state',
        placeholder: '审核状态',
        label: '审核状态',
        componentType: 'Select',
        dataSource: [
          // {
          //   name: '起草',
          //   value: '0',
          // },
          {
            name: '待审核',
            value: '1',
          },
          {
            name: '未通过',
            value: '2',
          },
          {
            name: '已通过',
            value: '3',
          },
          {
            name: '已作废',
            value: '4',
          },
        ],
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: false,
      },
      {
        name: 'signTime',
        placeholder: '发布',
        label: '发布时间',
        componentType: 'RangePicker',
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: true,
      },
      {
        name: 'signFormName',
        placeholder: '发布',
        label: '发布',
        componentType: 'DeptAndUser',
        dataSource: orgDeptList,
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: true,
        formOrgType: {
          COMP: 'signCompanyID',
          DEPT: 'signDepartmentID',
          POS: 'signPositionID',
          USER: 'signerID',
        }, //获取组织机构表单name, componentType: 'DeptAndUser', 必传
      },
      {
        name: 'createTime',
        placeholder: '创建',
        label: '创建时间',
        componentType: 'RangePicker',
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: true,
      },
      {
        name: 'createFormName',
        placeholder: '创建',
        label: '创建',
        componentType: 'DeptAndUser',
        dataSource: orgDeptList,
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: true,
        formOrgType: {
          COMP: 'createCompanyID',
          DEPT: 'createDepartmentID',
          POS: 'createPositionID',
          USER: 'createrID',
        }, //获取组织机构表单name, componentType: 'DeptAndUser', 必传
      },
    );
  } else if (switchObj?.key == 'MyVersionCheckTab') {
    switchSearch.push(
      {
        name: 'versionType',
        label: '版本类型',
        placeholder: '版本类型',
        componentType: 'Select',
        allowClear: true,
        dataSource: [
          {
            name: '安卓端',
            value: '0',
          },
          {
            name: '苹果端',
            value: '1',
          },
          {
            name: '电脑端',
            value: '2',
          },
        ],
        md: 7,
        sm: 24,
        whetherSenior: false,
      },
      // {
      //   name: 'publicNum',
      //   label: '版本号',
      //   placeholder: '版本号',
      //   componentType: 'Input',
      //   allowClear: true,
      //   md: 4,
      //   sm: 24,
      //   whetherSenior: false,
      // },
      {
        name: 'upgradeNote',
        placeholder: '升级内容',
        label: '升级内容',
        componentType: 'Input',
        allowClear: true,
        md: 7,
        sm: 24,
        whetherSenior: false,
      },
      {
        name: 'applyTime',
        placeholder: '申请',
        label: '申请时间',
        componentType: 'RangePicker',
        allowClear: true,
        md: 10,
        sm: 24,
        whetherSenior: false,
      },
      {
        name: 'applyFormName',
        placeholder: '申请',
        label: '申请',
        componentType: 'DeptAndUser',
        dataSource: orgDeptList,
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: true,
        formOrgType: {
          COMP: 'applyCompanyID',
          DEPT: 'applyDepartmentID',
          POS: 'applyPositionID',
          USER: 'applyerID',
        }, //获取组织机构表单name, componentType: 'DeptAndUser', 必传
      },
      {
        name: 'createTime',
        placeholder: '创建',
        label: '创建时间',
        componentType: 'RangePicker',
        allowClear: true,
        md: 8,
        sm: 24,
        whetherSenior: true,
      },
      {
        name: 'createFormName',
        placeholder: '创建',
        label: '创建',
        componentType: 'DeptAndUser',
        dataSource: orgDeptList,
        allowClear: true,
        md: 6,
        sm: 24,
        whetherSenior: true,
        formOrgType: {
          COMP: 'createCompanyID',
          DEPT: 'createDepartmentID',
          POS: 'createPositionID',
          USER: 'createrID',
        }, //获取组织机构表单name, componentType: 'DeptAndUser', 必传
      },
    );
  }
  return switchSearch;
};
export { getVersionManageSearchColumns };
